home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume2 / workbnch / oneplane.11 < prev   
Text File  |  1988-12-28  |  6KB  |  202 lines

  1. Path: xanth!nic.MR.NET!hal!cwjcc!tut.cis.ohio-state.edu!bloom-beacon!apple!bbn!ulowell!page
  2. From: page@swan.ulowell.edu (Bob Page)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v02i103:  oneplane - make workbench screen one plane v1.1
  5. Message-ID: <10939@swan.ulowell.edu>
  6. Date: 28 Dec 88 19:07:53 GMT
  7. Organization: University of Lowell, Computer Science Dept.
  8. Lines: 191
  9. Approved: page@swan.ulowell.edu
  10.  
  11. Submitted-by: erd@cis.ohio-state.edu (Ethan R. Dicks)
  12. Posting-number: Volume 2, Issue 103
  13. Archive-name: workbench/oneplane11.1
  14.  
  15. [New version for Lattice v5.0 ..Bob]
  16.  
  17. #    This is a shell archive.
  18. #    Remove everything above and including the cut line.
  19. #    Then run the rest of the file through sh.
  20. #----cut here-----cut here-----cut here-----cut here----#
  21. #!/bin/sh
  22. # shar:    Shell Archiver
  23. #    Run the following text with /bin/sh to create:
  24. #    OnePlane.c
  25. #    Makefile
  26. #    OnePlane.uu
  27. # This archive created: Wed Dec 28 14:04:56 1988
  28. cat << \SHAR_EOF > OnePlane.c
  29. /*
  30.  
  31.  OnePlane.c - program to steal bottom bitplane from workbench screen
  32.  
  33. Ethan Dicks
  34. (c) 15-Nov-1988
  35.  
  36. Version 1.1
  37. (c) 14-Dec-1988
  38.  
  39. This progam is *not* in the public domain, but may be freely redistributed on
  40. the condition that it is not sold, nor used in any commercial or shareware
  41. package without express written permission of the author.  This program may
  42. be included in a freely redistributable library, including, but not limited
  43. to the Fred Fish library collection.  In other words, selling this program
  44. is right out, but giving it away is encouraged.
  45.  
  46. I got the encouragement for this program from the discussion on comp.sys.amiga
  47. regarding fast text scrolling.  Someone called for a program to reduce the
  48. Workbench screen to 1 bitplane to enhance the speed of CON: output.
  49.  
  50. COMPILATION INSTUCTIONS:
  51.  
  52. This code will compile under either Lattice C, V4.01 or V5.00, although
  53. V5.00 will produce a 28 byte smaller executable.  Currently, Lattice V4.01
  54. produces a 468 byte executable, and V5.00 produces a 440 byte executable.
  55. Who says C has to be bloated!
  56.  
  57. To compile, either use LMK and the provided Makefile or use the commands:
  58.  
  59. lc -b0 -v oneplane.c
  60. blink oneplane.o SC SD ND
  61.  
  62. This is why some of the structure looks odd; I don't link with any external
  63. files, not even startup code.  I know that the program could be made even
  64. smaller, but what do want for a one night's hack?
  65.  
  66.  
  67. HOW IT WORKS:
  68.  
  69. In the structure GfxBase, there is a field, ActView, which describes the 
  70. current ViewPort.  This program uses the active viewport information to
  71. aquire the active BitPlane structure, which contains information about how
  72. many bitplanes are in use, their location in memory, the number of rows in
  73. the bitplane, and the number of bytes in each row.  With this information,
  74. is it trival to change the number of bitplanes down by one, and to free
  75. up the memory held by the highest bitplane.  The request is checked in case
  76. this is the only bitplane allocated.  The advantage of this system is that
  77. the number of bitplanes can be increased and decreased at will, without
  78. fear of a visit from the GURU.
  79.  
  80. Most of the information I got came from the RKM graphic primitives section,
  81. in the Libraries and Devices volume, especially the examples, and most of the
  82. rest came from picking apart the include files.
  83.  
  84. */
  85.  
  86. #include <exec/types.h>
  87. #include <exec/execbase.h>
  88. #include <intuition/intuition.h>
  89. #include <graphics/gfxbase.h>
  90. #include <proto/exec.h>
  91. #include <proto/intuition.h>
  92. #include <proto/graphics.h>
  93.  
  94. #define MIN_DEPTH 1
  95.  
  96.  
  97. #pragma libcall ExecBase FreeMem d2 0902
  98. #pragma libcall IntuitionBase RemakeDisplay 180 00
  99. #pragma libcall ExecBase CloseLibrary 19e 901
  100. #pragma libcall ExecBase OpenLibrary 228 0902
  101.  
  102. struct View *currentview;    /* pointer to active View */
  103. struct ViewPort *currentvp;    /* pointer to active ViewPort */
  104. struct RasInfo *currentri;    /* pointer to active RasInfo */
  105. struct BitMap *b;        /* pointer to current BitMap */
  106.  
  107. /* struct Execbase *ExecBase; */
  108. struct GfxBase *GfxBase;
  109. struct IntuitionBase *IntuitionBase;
  110. struct ExecBase *ExecBase, **EBase;
  111.  
  112.  
  113.  
  114. /* 
  115.     Here goes nuthin'
  116. */
  117. void main()
  118.  
  119. {
  120. /* Set the ExecBase pointer manually, since we do not link with anybody */
  121.     EBase = (struct ExecBase **)(4L);
  122.     ExecBase = *EBase;
  123.  
  124. /* Open the graphics.library and the intuition.library */
  125.  
  126. /* error checking not done, because if they won't open, the system is hosed */
  127.     GfxBase
  128.         = (struct GfxBase *)OpenLibrary("graphics.library",0);
  129.  
  130.     IntuitionBase
  131.         = (struct IntuitionBase *)OpenLibrary("intuition.library",0);
  132.  
  133. /* Here goes with the pointer game... the idea is to end up at the BitMap */
  134.  
  135.     currentview = GfxBase -> ActiView;    /* get current View */
  136.     currentvp = currentview -> ViewPort;    /* get current ViewPort */
  137.     currentri = currentvp -> RasInfo;    /* get current RasInfo */
  138.     b      = currentri -> BitMap;        /* get current BitMap */
  139.  
  140. /* And here is where we fiddle with the numbers */
  141.  
  142. /* ---> ONLY DO THIS IF THERE ARE BITPLANES LEFT TO REMOVE <--- */
  143.     if ( (b -> Depth) > MIN_DEPTH) {
  144.  
  145.         b -> Depth -= 1;
  146.         FreeMem( (b -> Planes)[(b -> Depth)],
  147.              (b-> Rows) * (b -> BytesPerRow) );
  148.  
  149.     }
  150.  
  151. /* Now that we are done fiddling with it, redraw the display */
  152.     RemakeDisplay();
  153.     
  154. /* Now clean up and go home */
  155.     CloseLibrary((struct Library *)GfxBase);
  156.     CloseLibrary((struct Library *)IntuitionBase);
  157. }
  158.  
  159. void MemCleanUp(){}
  160. SHAR_EOF
  161. cat << \SHAR_EOF > Makefile
  162. # -------------------------------------------
  163. # Makefile for Oneplane v1.1
  164. # Ethan Dicks 14-Dec-1988
  165. # -------------------------------------------
  166.  
  167. LCFLAGS = -b0 -v
  168. LNFLAGS  = SC SD ND
  169.  
  170. OnePlane.o:    OnePlane.c
  171.  
  172.     lc $(LCFLAGS) OnePlane
  173.  
  174. OnePlane:    OnePlane.o
  175.  
  176.     blink OnePlane.o $(LNFLAGS)
  177.  
  178. SHAR_EOF
  179. cat << \SHAR_EOF > OnePlane.uu
  180.  
  181. begin 777 OnePlane
  182. M```#\P`````````#``````````(````X````"0````@```/I````."\"<`0CP
  183. MP````!PB>0```!P@42/(````&$/Y`````'``+$A.KOW8(\`````00_D````2Y
  184. M<`!.KOW8(\`````4('D````0(^@`(@`````B>0`````CT0````0B>0````0CC
  185. MZ0`D````"")Y````""/I``0````,(GD````,$BD`!70!L@)C,B0!4P(@>0``,
  186. M``P10@`%<``0`B(`2,'E@2)(T\$P*``",A#`P2)I``@L>0```!A.KO\N+'D`P
  187. M```43J[^@")Y````$"QY````&$ZN_F(B>0```!1.KOYB)!].=4YU```#[```5
  188. M``(````!````+@```!H````4`````@```-(```#(````P@```+@```"N````C
  189. MB@```'8```!P````:````&(```!:````5````$X```!(````0````#H````H@
  190. M````%`````P````&`````````_(```/J````"6=R87!H:6-S+FQI8G)A<GD`%
  191. C`&EN='5I=&EO;BYL:6)R87)Y`````_(```/K````"````_)S9
  192. ``
  193. end
  194. size 440
  195. SHAR_EOF
  196. #    End of shell archive
  197. exit 0
  198. -- 
  199. Bob Page, U of Lowell CS Dept.  page@swan.ulowell.edu  ulowell!page
  200. Have five nice days.
  201.